//
//  NoCarTipView.m
//  BalanceCar
//
//  Created by 郑信鸿 on 17/6/28.
//  Copyright © 2017年 郑信鸿. All rights reserved.
//

#import "NoCarTipView.h"
#import "SeparateLineView.h"
#import "NSAttributedString+text.h"

@implementation NoCarTipView


- (instancetype)init{
    
    if (self = [super init]) {
        
        [self bulidSubViews];
    }
    
    return self;
}


- (void)bulidSubViews{
    
    UILabel *label = [[UILabel alloc] init];
    [self addSubview:label];
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:@"未发现车辆，请保持车辆有电并且靠近手机，再重新尝试"];
    [attri setLineSpacing:5];
    label.attributedText = attri;
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor colorFromHexCode:@"#666666"];
    label.font = [UIFont systemFontOfSize:17];
    label.numberOfLines = 2;
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_offset(40);
        make.left.mas_offset(20);
        make.right.mas_offset(-20);
    }];
    SeparateLineView *line = [[SeparateLineView alloc] init];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.bottom.mas_offset(-51);
        make.height.mas_offset(0.5);
    }];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:button];
    [button setTitle:@"重试" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:19];
    [button setTitleColor:[UIColor colorFromHexCode:@"#333333"] forState:UIControlStateNormal];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_offset(0);
        make.height.mas_offset(50);
        make.width.mas_offset(100);
        make.centerX.mas_offset(0);
    }];
    [button addTarget:self action:@selector(RetryAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)RetryAction:(UIButton *)button{
    
    
    if ([_delegate respondsToSelector:@selector(tipViewWillHideWithTipView:)]) {
        
        [_delegate tipViewWillHideWithTipView:self];
    }
   
}



@end
